import org.omg.IOP.TAG_RMI_CUSTOM_MAX_STREAM_FORMAT;

import java.io.Reader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: Administrator
 * \* Date: 2022/5/5
 * \* Time: 14:28
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
public class TestDemo {

//    输入：fruits = [0,1,2,2]
//    输出：3
//    解释：可以采摘 [1,2,2] 这三棵树。
//    如果从第一棵树开始采摘，则只能采摘 [0,1] 这两棵树。
    public int totalFruit(int[] tree) {
        if(tree == null || tree.length == 0) return 0;
        int n = tree.length;
        Map<Integer,Integer> map = new HashMap<>();
        int maxLen = 0;
        int left = 0;
        for (int i = 0; i < n; i++) {
            map.put(tree[i],map.getOrDefault(tree[i],0) + 1);
            while (map.size() > 2){
                map.put(tree[left], map.get(tree[left]) - 1);
                if(map.get(tree[left]) == 0){
                    map.remove(tree[left]);
                }
            }
            maxLen = Math.max(maxLen, i - left + 1);
        }
        return maxLen;
    }




//    输入：target = 7, nums = [2,3,1,2,4,3]
//    输出：2
//    解释：子数组 [4,3] 是该条件下的长度最小的子数组。

    public int minSubArrayLen(int target, int[] nums) {
        int i = 0;
        int j = 0;
        int sum = 0;
        int result = Integer.MAX_VALUE;
        int len = 0;
        while (j < nums.length){
            j = i;
            sum += nums[j];
            j++;
            while (sum >= target){
                len = j - i + 1;
                result = result < len ? result :len;
                sum -= nums[i];
                i++;
            }
        }
        return result == Integer.MAX_VALUE ?0 :result;
    }


    public int minSubArrayLen1(int target, int[] nums) {
        int sum = 0;
        int len = 0;
        int result = Integer.MAX_VALUE;
        for(int i = 0;i < nums.length;i++){
            sum = 0;
            for (int j = i; j < nums.length; j++) {
                sum = sum + nums[j];
                if(sum >= target){
                    len = j - i + 1;
                    result = result < len ? result : len;
                    break;
                }
            }
        }
        return result == Integer.MAX_VALUE ? 0 : result;
    }

    public boolean backspaceCompare(String s, String t) {
        StringBuilder sb1 = new StringBuilder();
        StringBuilder sb2 = new StringBuilder();
        for(char c: s.toCharArray()){
            if(c != '#'){
                sb1.append(c);
            }else if (sb1.length() > 0){
                sb1.deleteCharAt(sb1.length() - 1);
            }
        }
        for(char c: t.toCharArray()){
            if(c != '#'){
                sb2.append(c);
            }else if(sb2.length() > 0){
                sb2.deleteCharAt(sb2.length()-1);
            }
        }
        return sb1.toString().equals(sb2.toString());
    }


        public int[] sortedSquares(int[] nums) {
            int[] arr = new int[nums.length];
            int left = 0;
            int right = nums.length - 1;
            int index = nums.length - 1;
            while (left <= right) {
                if (nums[left] * nums[left] > nums[right] * nums[right]) {
                    arr[index] = nums[left] * nums[left];
                    index--;
                    left++;
                } else {
                    arr[index] = nums[right] * nums[right];
                    index--;
                    right--;
                }
            }
            return arr;
        }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            String str1 = sc.nextLine();
            String str2 = sc.nextLine();
            String[] str3 = str1.split("/");
            String[] str4 = str2.split("/");
            long a1 = Integer.valueOf(str3[0]);
            long a2 = Integer.valueOf(str3[1]);
            long b1 = Integer.valueOf(str4[0]);
            long b2 = Integer.valueOf(str4[1]);

        }
    }
    //通分
    public static long[] passPoint(long a1,long a2,long b1,long b2){
        long [] arr = new long[4];
        arr[0] = a1 * b1;
        arr[1] = a2 * b2;
        arr[2] = b1 * a2;
        arr[3] = b2 * a1;
        return arr;
    }

    //约分

    //加法
}
